#include "StdAfx.h"
#include "PathUtils.h"

#include <Shlwapi.h>

#include <vector>


tchar_string PathUtils::shorten(tchar_string const& fullPath)
{
    DWORD size = GetShortPathName(fullPath.c_str(), 0, 0);
    std::vector<TCHAR> buf(size);
    GetShortPathName(fullPath.c_str(), &buf[0], size);
    return &buf[0];
}

tchar_string PathUtils::pathCombine(tchar_string const& p1, tchar_string const& p2)
{
    std::vector<TCHAR> buffer(p1.length() + p2.length() + 1 + 1);
    PathCombine(&buffer[0], p1.c_str(), p2.c_str());
    return &buffer[0];
}

tchar_string PathUtils::removeFileSpec(tchar_string const& full)
{
    std::vector<TCHAR> buffer(full.length());
    full.copy(&buffer[0], full.length());
    PathRemoveFileSpec(&buffer[0]);
    return &buffer[0];
}